package com.wanxi.dao.impl;//package com.wanxi.dao.impl;
//
//import com.wanxi.dao.CompanyDao;
//import com.wanxi.model.ClothingStyleModel;
//import com.wanxi.model.CompanyModel;
//import com.wanxi.util.JDBC;
//
//import java.sql.ResultSet;
//import java.sql.SQLException;
//import java.util.ArrayList;
//import java.util.List;
//
//public class CompanyImpl implements CompanyDao {
//    @Override
//    public int enable(CompanyModel companyModel) {
//        return 0;
//    }
//
//    @Override
//    public int isShow(CompanyModel companyModel) {
//        String sql="update company set is_show =case is_show when 0 then 1 when 1 then 0 when -1 then 1 end where id="+companyModel.getId()+"";
////        String sql="update product set enable=1-enable where id="+productModel.getId()+"";
////        String sql = " update product set is_show=is_show^1 where id=  '"+ productModel.getId() + "'";
//
//        return JDBC.update(sql);
//    }
//
//    @Override
//    public int isRecommend(CompanyModel companyModel) {
//        return 0;
//    }
//
//    @Override
//    public int whereShow(CompanyModel companyModel) {
//        return 0;
//    }
//
//    @Override
//    public int add(CompanyModel companyModel) {
//        String sql ="insert into company(phone,qq,is_show,email,code,address) values('"+companyModel.getPhone()+"','"+companyModel.getQq()+"','"+companyModel.getIsShow()+"','"+companyModel.getEmail()+"','"+companyModel.getCode()+"','"+companyModel.getAddress()+"')";
//        return JDBC.update(sql);
//    }
//
//    @Override
//    public int update(CompanyModel companyModel) {
//        String sql=" update company set ";
//        if (!"".equals(companyModel.getCode())) {
//            sql += " code ='" + companyModel.getCode() + "',";
//        }
//        if (companyModel.getQq()!=-1) {
//            sql += " qq ='" + companyModel.getQq() + "',";
//        }
//
//        if (companyModel.getIsShow()!=-1) {
//            sql += " is_show  ='" + companyModel.getIsShow() + "',";
//        }
//        if (!"".equals(companyModel.getAddress())) {
//            sql += " address ='" + companyModel.getAddress() + "',";
//        }
//        if (!"".equals(companyModel.getEmail())) {
//            sql += " email ='" + companyModel.getEmail() + "',";
//        }
//        if (!"".equals(companyModel.getPhone())) {
//            sql += " phone ='" + companyModel.getPhone() + "',";
//        }
//        sql += " update_time=now()";
//        sql += " where id=" + companyModel.getId();
//        return JDBC.update(sql);
//    }
//
//    @Override
//    public int delete(CompanyModel companyModel) {
//        String sql=" delete from company where id = "+companyModel.getId();
//        return JDBC.update(sql);
//    }
//
//    @Override
//    public CompanyModel findById(CompanyModel companyModel) {
//        String sql = " select * from company where id = "+companyModel.getId();
//        ResultSet resultSet = JDBC.query(sql);
//        CompanyModel model = null;
//        try {
//            while (resultSet.next()) {
//                model = new CompanyModel();
//                model.setQq(resultSet.getInt("qq"));
//                model.setPhone(resultSet.getString("phone"));
//                model.setAddress(resultSet.getString("address"));
//                model.setIsShow(resultSet.getInt("is_show"));
//                model.setCode(resultSet.getString("code"));
//                model.setEmail(resultSet.getString("email"));
//                model.setId(resultSet.getInt("id"));
//
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        }
//        return model;
//    }
//
//    @Override
//    public List<CompanyModel> findAll(CompanyModel companyModel) {
//        String sql = " select * from company where 1=1";
//        ResultSet query = JDBC.query(sql);
//        List<CompanyModel> list=new ArrayList<>();
//        try {
//            while (query.next()){
//                CompanyModel model=new CompanyModel();
//                model.setQq(query.getInt("qq"));
//                model.setPhone(query.getString("phone"));
//                model.setAddress(query.getString("address"));
//                model.setIsShow(query.getInt("is_show"));
//                model.setCode(query.getString("code"));
//                model.setEmail(query.getString("email"));
//                model.setId(query.getInt("id"));
//                list.add(model);
//            }
//        } catch (SQLException e) {
//            e.printStackTrace();
//        } ;
//        return list;
//    }
//
//    @Override
//    public int count(CompanyModel companyModel) {
//        String sql = "select count(*) count from company ";
//        return JDBC.count(sql);
//    }
//}
